package gbench.appdemo.crawler.junit.analyzer;

import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import gbench.appdemo.crawler.analyzer.lexer.Trie;
import gbench.common.fs.FileSystem;
import gbench.common.tree.LittleTree;

public class JunitCorpus {
    
    @Test
    public void foo() {
        final var trie = new Trie<String>();// 根节点树
        FileSystem.utf8lines("keywords.txt",this.getClass()).forEach(e->{
            Stream.of(e.strip().split("[:、\n]+")).map(p->p.split(""))
            .forEach(points->Trie.addPoints2Trie(trie, points));
        });
        
        Trie.traverse(trie, e->{// 为节点增肌属性。
            e.addAttribute("meaning", e.getPath(s->s.collect(Collectors.joining())));
        });
        
        final var child = trie.removeTrie("司马懿".split(""),true);
        
        Trie.traverse(child, e->{
            System.out.println(LittleTree.ident(e.getLevel())+e.getValue()+"\t meaning:"+e.getAttribute("meaning"));
        });
        
        Trie.traverse(trie, e->{
            System.out.println(LittleTree.ident(e.getLevel())+e.getValue()+"\t meaning:"+e.getAttribute("meaning"));
        });
        
    }

}
